import java.awt.Dimension;
import java.awt.geom.Point2D;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

public class MatrixInput extends LabelInput {
	private Arrow arrow;
	private Representation repr;
	private String[][] map;
	
	public MatrixInput(Representation repr, Arrow arrow) {
		this.repr = repr;
		this.arrow = arrow;
		map = repr.getMap(arrow);
		if(map.length==0 || map[0].length==0){
			return;
		}
		setModel(new DefaultTableModel(map.length, map[0].length));
		for (int i=0; i<map.length; i++){
			for(int j=0; j<map[0].length; j++){
				setValueAt(map[i][j], i, j);
			}
		}
		point = arrow.getLabelPoint();
		init();
	}
	
	protected void write(){
		if(map.length==0 || map[0].length==0){
			return;
		}
		for (int i=0; i<map.length; i++){
			for(int j=0; j<map[0].length; j++){
				map[i][j] = (String) getValueAt(i, j);
			}
		}
		repr.setMap(arrow, map);
	}
}
